package com.yntsoft.controller;



import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springside.modules.web.Servlets;

import com.github.pagehelper.PageInfo;
import com.yntsoft.entity.Role;
import com.yntsoft.mybatisUtil.Page;
import com.yntsoft.service.RoleService;
import com.yntsoft.util.Constant;

/**
 * 角色控制层
 * @author Tony
 */
@Controller
@RequestMapping("table")
public class StuBootStrapTable {

	@Autowired
	private RoleService roleService;
	
	@RequestMapping("toTable")
	public String toBootStrapPage(){
		return "table/bootStrapTable";
	}
	
	/**
	 * 查询角色列表
	 * @return 
	 */
	@RequestMapping("list") 
	@ResponseBody
	public Object roleList (HttpServletRequest request,Model model){
		Map<String, Object> searchParams = Servlets.getParametersStartingWith(request, "search_");
		/*PageInfo<Role> roles = roleService.queryRoleList(searchParams,Constant.pageSize);*/
		Page<Role> roles = roleService.queryPageRoleList(searchParams,Constant.pageSize);
		searchParams.put("total", roles.getTotal());  
		searchParams.put("rows", roles.getDatas());
 		return searchParams;
	}
}
